package com.zynn.api.yinian.zuul.util;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author jerry-liqi
 *
 * 工具类
 */
public class StreamUtil {



    /**
     * @param is 输入流
     * @return String 返回字符串
     * @throws IOException
     */
    public static String readFromStream(InputStream is) throws IOException {
        ByteArrayOutputStream bb = new ByteArrayOutputStream();
        String st = "";
        byte[] buffer = new byte[1024];
        int len;
        while ((len = is.read(buffer)) != -1) {
            bb.write(buffer, 0, len);
        }
        is.close();
        byte[] data = bb.toByteArray();
        String result = new String(data, "UTF-8");
        return result;
    }
}